package com.lutzyt.delivery.controller;

import com.lutzyt.delivery.bean.UserRole;
import com.lutzyt.delivery.service.UserRoleService;
import com.lutzyt.delivery.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 * @author zyt
 */
@RestController
@RequestMapping("/api/user/role")
@Api(tags = "")
public class UserRoleController {
  private UserRoleService userRoleService;

  @GetMapping("/{id}")
  @ApiOperation("通过ID查询单个")
  public Result<UserRole> findById(@ApiParam("ID") @PathVariable("id") Integer id) {
    return Result.success(userRoleService.findById(id));
  }


  @PostMapping
  @ApiOperation("新增")
  public Result<Void> insert(@RequestBody UserRole userRole) {
    userRoleService.insert(userRole);
    return Result.success();
  }

  @Autowired
  public void setUserRoleService(UserRoleService userRoleService) {
    this.userRoleService = userRoleService;
  }
}
